package org.msd.controller;
import org.apache.ibatis.annotations.Param;
import org.msd.model.Order;
import org.msd.service.iml.Orderservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@Controller
@RequestMapping("/ordert")
public class OrderContrller {
    /*
    实现订单业务
     */
    @Autowired
    private Orderservice orderservice;
    @RequestMapping("orderw")
    @ResponseBody
    public String  Ordel(@RequestParam("Ordersfogoods")int Ordersfogoods, @RequestParam("date") int date, @RequestParam("price")double  price, @RequestParam("username")String username){
    double  Orderprice= (double)(date*price);//计算价格
      int  or=orderservice.insertOrderDaO(Ordersfogoods,username,Orderprice);//插入
     if (or==1){
        return "支付成功";
     }else {

     }
        return null;
    }
    @RequestMapping("checki")
    /*
    根据用户名查询订单
     */
    @ResponseBody
    public  List<Order> CHECKI(@Param("username") String username){
    List<Order> orderList=orderservice.SERErOrder(username);
       return orderList;

    }
    /*
    跳转支付成功页面
     */
    @RequestMapping("defrayed")
    public String DEFRAYED(){
        return  "registrationsuccess";
    }

}
